<!--
 * @Descripttion: 
 * @Version: 
 * @Author: gaohj
 * @Date: 2022-11-09 16:10:38
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2022-11-09 16:53:07
-->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>
        <span>999</span>
        <p>我是div的子标签</p>
        <span>666</span>
    </div>
    <script>
        // replaceChild()

        // 父节点.replaceChild(把谁换上,把谁换下);

        // 创建一个新标签  替换 原来的p标签  

        var newSpan = document.createElement('span');
        newSpan.innerText = 777;
        // console.log(newSpan)

        var divEle = document.querySelector('div');
        var pEle =  document.querySelector('p');


        divEle.replaceChild(newSpan,pEle);


        
    </script>
</body>
</html>